package main

import (
	"fmt"
	"github.com/nacos-group/nacos-sdk-go/clients"
	"github.com/nacos-group/nacos-sdk-go/common/constant"
	"github.com/nacos-group/nacos-sdk-go/vo"
)

func main(){
	sc :=[]constant.ServerConfig{
		{
			IpAddr: "192.168.178.120",
			Port: 8848,
		},
	}
	cc :=constant.ClientConfig{
		NamespaceId:         "cdd290d1-79bc-46cc-8689-5a1ad9a177d7", // 如果需要支持多namespace，我们可以场景多个client,它们有不同的NamespaceId
		TimeoutMs:           5000,
		NotLoadCacheAtStart: true,
		LogDir:              "tmp/nacos/log",
		CacheDir:            "tmp/nacos/cache",
		RotateTime:          "1h",
		MaxAge:              3,
		LogLevel:            "debug",
	}
	configClient,err :=clients.CreateConfigClient(map[string]interface{}{
		"serverConfigs":sc,
		"clientConfig":cc,
	})
	if err != nil {
		panic(err)
	}
	content,err :=configClient.GetConfig(vo.ConfigParam{
		DataId: "user-api",
		Group: "v1",
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(content)


}